package net.wofly.right.validator;

import org.springframework.util.StringUtils;

public class FuncListValidator {
    
    /**
     * 换行符
     */
    private static String lineSeparator = System.getProperty("line.separator");
    
    public static String validateFuncListID(String funcListID) {
        StringBuffer stringBuffer = new StringBuffer();
        if (StringUtils.isEmpty(funcListID)) {
            stringBuffer.append("功能ID不能为空！").append(lineSeparator);
        }
        return stringBuffer.toString();
    }
    
    public static String validateModifyFuncListParams(String funcListID,String funcName,String funcModule,Integer funcType,String funcUrl) {
        StringBuffer stringBuffer = new StringBuffer();
        
        if (StringUtils.isEmpty(funcListID)) {
            stringBuffer.append("funcListID不能为空").append(lineSeparator);
        }
        validateCommon(funcName, funcModule, funcType, funcUrl,stringBuffer);
        return stringBuffer.toString();
    }
    
    public static String validateAddFuncListParams(String funcName,String funcModule,Integer funcType,String funcUrl) {
        StringBuffer stringBuffer = new StringBuffer();
        validateCommon(funcName, funcModule, funcType, funcUrl, stringBuffer);
       
        return stringBuffer.toString();
    }
    
    private static void validateCommon(String funcName,String funcModule,Integer funcType,String funcUrl, StringBuffer stringBuffer) {
        if (StringUtils.isEmpty(funcName)) {
            stringBuffer.append("功能名称funcName不能为空").append(lineSeparator);
        }
        if (StringUtils.isEmpty(funcModule)) {
            stringBuffer.append("功能所属模块funcModule不能为空").append(lineSeparator);
        }
        if (StringUtils.isEmpty(funcType)) {
            stringBuffer.append("功能类型funcType不能为空").append(lineSeparator);
        }
        if (StringUtils.isEmpty(funcUrl)) {
            stringBuffer.append("功能URL不能为空").append(lineSeparator);
        }
    }
    
}
